package Graphic;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;

public class MainFrame implements KeyListener{
	JPanel firstPanel;
	public GamePanel gamePanel;
	JFrame frame; 
	public MainFrame(){
		frameSet();
	}
	private void frameSet(){
		//frame set
		frame = new JFrame();
		frame.setResizable(false);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		//panel set
		firstPanel = new JPanel(null);
		gamePanel = new GamePanel();
		
		//image, label, background set
		ImageIcon img_background = new ImageIcon("images/main.jpg");
		JLabel lab_bg = new JLabel("", img_background,SwingConstants.CENTER);
		lab_bg.setSize(1024,768);
		lab_bg.setLocation(0,0);
		
		//panel view set
        firstPanel.add(lab_bg);
        firstPanel.setPreferredSize(new Dimension(1024,768));
        firstPanel.setVisible(true);
        
        //frame view add set
        frame.add(firstPanel);
        frame.add(gamePanel,BorderLayout.EAST);
        frame.pack();
        frame.setVisible(true);
        
        frame.addKeyListener(this);
	}
	@Override
	public void keyPressed(KeyEvent e) {
		switch(e.getKeyCode()){
		default:
			firstPanel.setVisible(false);
			firstPanel.removeAll();
			gamePanel.setVisible(true);
		}
	}
	@Override
	public void keyReleased(KeyEvent e) {
	}
	@Override
	public void keyTyped(KeyEvent e) {
	}
}
